<?php
// created by: alfin akhret
// related files :
// model/mdue_date.php
// view/f-due-date.php
// view/grid-due-date.php
// library/serversidedatatables.php

class Consignment_list extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('mconsignment_list');
        $this->load->model('mglobal');       
        $this->load->model('mmaster');
        $this->load->library('form_validation');
        $this->load->library('cfpdf');
        $this->load->library('enc');
        // $this->load->library('encrypt');
    }

    public function index($lastId="")
    {
        $data['lastId'] = $lastId; //<-- donny adiwilaga
        $data['template'] = "shell/smooth";
        $data['main_view'] = 'f-consignment-list';

        $this->load->view($data['template'], $data);
        
    }

    //cari tanggal data jatuh tempo
    function get_consignment_list() 
    {
        $cluster_id = $this->mglobal->user_cluster($this->session->userdata("username"));

        $result = $this->mconsignment_list->get_consignment_list($cluster_id);

        //encode
        foreach ($result['aaData'] as $r => &$value) 
        {
            $value[0] = $this->enc->fogit($value[0]);
        }
        
        //penambahan nomor statis untuk grid SSP
        $start=$_GET['iDisplayStart'];
        $result['iDisplayStart']=$start;
        echo json_encode($result);
        
    }

    function defoger()
    {
        $result = $this->enc->defog($this->input->post('str'));
        echo $result;  
    }

    //close kasus jatuh tempo
    function close($sell_in_id)
    {
        $result= $this->mdue_date->close($sell_in_id);
        $this->session->set_flashdata('message', 'record has been closed');
        redirect(base_url() . "index.php/due_date");
    }

    function topdf($sell_in_id)
    {
        //pending
    }

}